<?php
/**
  * Template Formular
  * @param   : _[id], _[title], _[colForms], _[colData]
  *
  * @info    : "id"=>, "title"=>"", "name"=>"", "type"=>"", "validate"=>"", "pos"=>, "width"=>, "value"=>"", "active"=>true
  *
  * @e.datum : 30.12.2010
  * @l.datum : 05.01.2011
  * @version : beta
 **/
require_once('calendar/classes/tc_calendar.php');

  session_start();
  //$error_reporting = error_reporting(E_ERROR);
  if($bSessionID)
    echo session_id();
?>


 <FORM action='?view=formcontent&id=<?php echo $this->_['id'] ?>' method='POST'>
    <?php
    echo '<H1 class="ueberschrift">' . ($this->_['title']) . '</H1>';
    echo '<H3 class="ueberschrift">' . ($this->_['subtitle']) . '</H3>';
    echo '<hr>';
    echo '<TABLE>';
    $readonlyALL=null;
    foreach ($this->_['colForms'] as $col) {
        if ($col['active'] == true) {
            if ($col['type'] != "code") {
                switch ($col['type']) {
                    case "splitter":
                        echo '<TR><TD colspan=2><h2 class="ueberschrift">'.$col[title].'</h2><hr /></TD>';
                        break;
                    default:
                        echo '<TR><TD>';
                        //echo ($col['title']);
                        echo ('<LABEL class="tab">'.$col['title']);
                        if($col['required'])
                          echo (' *');
                        echo('</LABEL>');
                        echo '</TD><TD>';
                        break;
                }
                
                switch ($col['type']) {
                    case "select": echo "<SELECT name='$col[name]'>";
                        foreach ($col['data'] as $data) {
                            if ($_SESSION[$col[name]] == $data[contend])
                                echo "<OPTION value='".($data[contend])."' selected='selected'>" . ($data['contend']);
                            else
                                echo "<OPTION value='".($data[contend])."'>" . ($data['contend']);
                        }
                        echo "</SELECT>";
                        break;

                    case "input" : 
                        $readonly = "";
                        //echo $col['readonly'];
                        if($col['readonly'])
                            $readonly = " readonly=\"readonly\"";
                        $test = $col['name'];
                        echo "<INPUT class='tab' name='".($col[name])."' value='".($_SESSION[$test])."'".$readonly."></INPUT>";
                        break;
                    case "date":    
                        echo "<INPUT class='tab' id=".$col[name]." name='".($col[name])."' value='".($_SESSION[$col[name]])."'></INPUT>";
                        break;
                    case "radio" :
                        echo ('<TABLE><TR><TD><LABEL>Ja</LABEL></TD><TD>');
                        echo ("<INPUT type='radio' name='".($col[name])."' value='+'".($_SESSION[$col['name']] == "+" ? " checked='checked'" : "")."/>");
                        echo ('</TD><TR><TD><LABEL>Nein</LABEL></TD><TD>');
                        echo ("<INPUT type='radio' name='".($col[name])."' value='-'".($_SESSION[$col['name']] == "-" ? " checked='checked'" : "")."/>");
                        echo ('</TD></TR></TABLE>');
                        break;

                    default : break;
                }
                echo "</TD>";
                echo "<TD class=\"infoCol\">";
                if($col['type']=="date"){
                        $myCalendar = new tc_calendar("$col[name]", true, false);
                                        $myCalendar->setIcon("calendar/images/iconCalendar.gif");
                                        $myCalendar->setDate(date('d'), date('m'), date('Y'));
                                        $myCalendar->setPath("calendar/");
                                        $myCalendar->setYearInterval(1960, 2015);
                                        $myCalendar->dateAllow('1960-01-01', '2015-12-31');
                                        $myCalendar->setDateFormat('j F Y');
                                        $myCalendar->setAlignment('left', 'bottom');
                                        $myCalendar->writeScript();
                }
                if($col[info] != "")
                        echo '<img class="fieldInfo" src="images/s_notice.png"/><span class="hint">'.$col[info].'<span class="hint-pointer">&nbsp;</span></span>';
                if ($col['err'] != "") {
                    echo '<IMG class="fieldError" src=images/s_error.png alt=fehler><p name="error" class="hint-error">Fehler: '.$col['err'].'<span class="hint-pointer-error">&nbsp;</span></p>';
                }
                echo "</TD>";
                echo "</TR>";
            } else {
                
                eval ($col['value']);
                
            }
        }
    }
    echo '</TABLE>';
    ?>
    <h3>(Die mit * gekennzeichneten Felder sind Pflichtfelder)</h3>
    <table>
        <tr>
            <td><label for="zurück"></label><input type="button" onclick="window.location.href='?view=formcontent&id=<?php echo $this->_['id'] - 2 ?>'"name="back" id="back" value="Zurück"></td>
            <td><label for="weiter"></label><input type="submit" name="senden" id="senden" value="Weiter"></td>
        </tr>
    </table>
</FORM>


